<template>
  <!-- 患者基本信息 -->
  <section class="patient-basic-info">
    <div class="head-box">
      <img v-if="patientInfo.head" :src="patientInfo.head|imageUrl" class="head-img" alt="">
      <img v-else src="@/img/unknown-avatar.png" class="head-img" alt="">
      <div v-if="patientInfo.levelId" class="vip-box">
        <el-tooltip :content="patientInfo.levelName" placement="top">
          <img src="@/img/icon-vip.png" alt="">
        </el-tooltip>
      </div>
    </div>
    <br>
    <div style="font-size:18px;">{{patientInfo.name}}</div>
    <div style="margin-top:5px;">
      <slot></slot>
    </div>
    <br>
    <div class="userinfo-item">
      档案号：{{patientInfo.archivesCode}}
    </div>
    <div class="userinfo-item">
      电话：{{patientInfo.mobile}}
    </div>
    <div class="userinfo-item">
      性别：{{patientInfo.sex|toSex}}
    </div>
    <div class="userinfo-item">
      <span>年龄：</span>
      <span v-if="patientInfo.age>17">{{patientInfo.age}}</span>
      <span v-else>{{patientInfo.birthday|toTimeContrast}}</span>
    </div>
    <div class="userinfo-item">
      身高：{{patientSignInfo.height}}CM
    </div>
    <div class="userinfo-item">
      体重：{{patientSignInfo.weight}}KG
    </div>
    <div class="userinfo-item">
      BMI 指数：{{patientSignInfo.bmi}}
    </div>
    <div class="userinfo-item">
      体温：{{patientSignInfo.temperatureType|changeAssist(temperatureType)}}&nbsp;&nbsp;{{patientSignInfo.temperature}}℃
    </div>
    <div class="userinfo-item">
      呼吸：{{patientSignInfo.breathing}}次/分钟
    </div>
    <div class="userinfo-item">
      脉搏：{{patientSignInfo.pulse}}次/分钟
    </div>
    <div class="userinfo-item">
      血压：{{patientSignInfo.diastolicpressure}}~{{patientSignInfo.systolicPressure}}
    </div>
    <div class="userinfo-item">
      血糖浓度：{{patientSignInfo.bloodsugarType |changeAssist(bloodsugarTypeArr)}} &nbsp;&nbsp;{{patientSignInfo.bloodsugar}}
    </div>
    <div class="userinfo-item">
      视力：左：{{patientSignInfo.leftEye}}&nbsp;&nbsp;右：{{patientSignInfo.rightEye}}
    </div>
    <div class="userinfo-item">
      氧饱和度：{{patientSignInfo.oxygenSaturation}}%
    </div>
    <div class="userinfo-item">
      疼痛评分：{{patientSignInfo.painScore}}分
    </div>
    <!-- <div v-if="cureId" class="userinfo-item">
      初步诊断：{{firstVisit}}
    </div> -->
  </section>
</template>
<script>
export default {
  props: ["patientId", "cureId"],
  data() {
    return {
      patientInfo: {},
      firstVisit: "",
      patientSignInfo: {},
      temperatureType: [],
      bloodsugarTypeArr: []
    };
  },
  async created() {
    let th = this;
    th.temperatureType = await th.getCommonConfigByKey("体温类型");
    th.bloodsugarTypeArr = await th.getCommonConfigByKey("血糖类型");
    th.getUserInfo();
  },
  mounted() {},
  methods: {
    //获取患者信息
    getUserInfo() {
      let th = this;
      let j = {
        patientId: th.patientId,
        cureId: th.cureId
      };
      th.$api.getPatientDetail(j).then(res => {
        if (res.executed) {
          th.patientInfo = res.data.patientInfo ? res.data.patientInfo : {};
          th.patientSignInfo = res.data.patientSignInfo
            ? res.data.patientSignInfo
            : {}; 
          const allergyList=res.data.allergyList;
          th.firstVisit = res.data.firstVisit;
          th.$emit("init", th.patientInfo,th.patientSignInfo,allergyList);
        }
      });
    }
    //获取患者
    // getPatientDetail() {
    //   const th = this;
    //   let j = {
    //     hpId: th.adminUser.hpId,
    //     patientId: th.patientId
    //   };
    //   th.$api.getThePatientLibraryById(j).then(res => {
    //     if (res.executed) {
    //       th.patientInfo = res.thePatientLibraryDetail;
    //     }
    //   });
    // }
  }
};
</script>
<style lang="scss" scoped>
.patient-basic-info {
  width: 220px;
  .head-box {
    position: relative;
    img {
      width: 100px;
      height: 100px;
    }
    .vip-box {
      position: absolute;
      left: 0;
      top: 0;
      img {
        width: 40px;
        height: 20px;
      }
    }
  }
  .userinfo-item {
    border-bottom: 1px solid #eee;
    padding: 10px 0;
  }
}
</style>
